package com.chinasofti.etc.alcohol.web;


import com.chinasofti.etc.alcohol.common.Result;
import com.chinasofti.etc.alcohol.dao.model.OrderS;
import com.chinasofti.etc.alcohol.dao.model.User;
import com.chinasofti.etc.alcohol.service.IOrderService;
import com.chinasofti.etc.alcohol.web.form.CheckoutInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lucas
 * @since 2019-05-30
 */
@Controller
@Slf4j
public class OrderController {

    @Autowired
    private IOrderService iOrderService;
    @RequestMapping(value = "order",method = RequestMethod.GET)
    public String orderQuery(ModelMap map, HttpSession session){
        User user= (User) session.getAttribute("user");
        List<OrderS> orderS=iOrderService.orderQuery(user.getUserNumber());
        map.addAttribute("order",orderS);
        return "wishlist";
    }

    @RequestMapping(value = "orders",method = RequestMethod.POST)
    @ResponseBody
    public void orderHandle(String order,int orderId){
        switch (order){
            case "取消订单" : iOrderService.modify(orderId,"申请取消订单");break;
            case "确认签收" : iOrderService.modify(orderId,"订单完成");break;
            case "申请退货" : iOrderService.modify(orderId,"申请退货");break;
            case "删除订单" : iOrderService.modify(orderId,"已归档");break;
            default :log.info("系统故障");
        }
    }





}

